home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
rmhead14.zip
/
RMHEADER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-03-14
|
5KB
|
166 lines
Program RmHeader;
Uses DOS, crt, ShowRem;
Const C_Max_lines = 50;
Version = 1.4;
{These variables are used by the whole program and procedures}
Var
Max_Regels : byte;
Lines : text;
Regels : array[0..50] of string;
Total_Rewritten : integer;
Procedure ReadConfig;
Procedure Fout;
Begin
Writeln('Error : can not open RMHEADER.CFG');
Halt(1);
End; {FOUT}
Var help_counter : integer;
help_string : string;
Begin
{Read in Config file}
Assign(Lines, 'rmheader.cfg');
{$I-}
Reset(lines);
if ioresult > 0 then fout;
{$I+}
Help_counter := 0;
Repeat
Readln(lines,help_string);
if help_string <> '' then Regels[help_counter] := help_string;
inc(help_counter);
if help_counter > C_Max_Lines then
Writeln ('Sorry, but my maximum is ',C_Max_Lines,' lines of a header.');
Until EOF(Lines) or (help_counter > C_Max_lines);
Close(lines);
Max_Regels := help_counter;
end; {READCONFIG}
Procedure Help;
Begin
Writeln('Remove Header was written to remove or simplify the headers of E-mail');
Writeln('messages and news messages.');
Writeln('This program MUST find the file RMHEADER.CFG. In the file RMHEADER.CFG');
Writeln('you can write the FIRST word of a line that should be included in the');
Writeln('converted file. The word should start with a capital and end with a '':''.');
Writeln('For example Name: and Subject: are valid.');
Writeln('When using this program the command line may have wildcards.');
Writeln('This program is free to use. You use the program at your own risk.');
Writeln('If you have any problems or suggetions you can E-mail me at :');
Writeln(' C.W.G.M.ENDERS@KUB.NL');
Writeln('Or mail me at :');
Writeln(' C.W.G.M. ENDERS');
Writeln(' Professor Verbernelaan 22');
Writeln(' 8016 HM TILBURG');
Writeln(' The Netherlands');
Halt(0);
END; {HELP}
Procedure Herschrijf (Filenaam : string);
Const Doel = 'Doel.txt';
var
FileIn, FileOut : Text;
teller, t2 : byte;
s : string;
b : Boolean;
Begin
{Read in the file to be converted}
if filenaam = 'RMHEADER.CFG' then exit;{skip this file}
if filenaam = 'DOEL.TXT' then exit;{skip this file}
Assign(FileIn, filenaam);
Reset(FileIn);
Assign(FileOut, doel);
Rewrite(fileout);
Teller := 0;
B:= false;
Repeat
Readln(FileIn, S);
Inc(teller);
for t2 := 0 to Max_Regels do
begin
If Pos(regels[t2],s) = 1 then
Begin
Writeln(FileOut, S);
B := TRUE;
end;{IF}
end;{FOR}
Until (S = '') or (teller > 50);
If B then { handel de doel.txt netjes af}
Begin
Writeln(fileout,s);
While not(eof(filein)) do
Begin
Readln(filein,s);
Writeln(fileout,s);
end;{WHILE}
Write (filenaam:14,'File Converted': 25);
Inc(Total_Rewritten);
Close(FileIn);
Close(fileout);
{Copy it back}
Assign(FileIn, doel);
Reset(FileIn);
Assign(FileOut, filenaam);
Rewrite(fileout);
While not(eof(filein)) do
Begin
Readln(filein,s);
Writeln(fileout,s);
end;{WHILE}
Writeln(' --- Rewritten');
Close(FileOut);
Close(FileIn);
Erase(FileIn);
end{THEN}
else
Begin
Writeln (filenaam:14,'File Not Converted': 25);
Close(FileIn);
Close(fileout);
Erase(fileout);
end;{ELSE}
END; {Herschrijf}
Var {Main Progam}
c_string : string;
t : byte;
DirInfo : SearchRec;
total : integer;
begin {Main Program}
Writeln('ReMove Header --- Version ',version:1:1,' --- Written by C. Enders ---- FREEWARE (1994).');
Total_Rewritten := 0;
If paramcount = 0 then
Begin
Writeln('Use RMHEADER <Filename> to remove the header of a file.');
Writeln('Use RMHEADER /? or -? for more info.');
halt(0)
end;
c_string := paramstr(1); {Lees het eerste woord op de commando regel}
if (c_string = '/?') or (c_string = '-?') then Help;
ReadConfig;
total := 0;
FindFirst(C_string, Archive, DirInfo);
while DosError = 0 do
begin
herschrijf(DirInfo.Name);
inc(total);
FindNext(DirInfo);
end;
Writeln('Number of files passed : ', total:6);
Writeln('Number of files converted : ',Total_Rewritten:6);
END. {Program}